import {createBrowserRouter, Navigate} from 'react-router-dom'
import Main from "../view/main";
import Home from "../view/Home";
import User from "../view/User";
import Mall from "../view/Mall";
import Login from "../view/Login";
import MyHooks from "../view/Hooks";
import MyReactMemo from "../view/ReactMemo";

const routes = [
    {
        path: '/',
        Component: Main,
        children: [
            // 重定向
            {
                path: '/',
                element: <Navigate to='home' replace/>
            },
            {
                path: 'home',
                Component: Home,
            },
            {
                path: 'user',
                Component: User,
            },
            {
                path: 'mall',
                Component: Mall,
            },
            {
                path: 'mall',
                Component: Mall,
            },
            {
                path: 'other/hooks',
                Component: MyHooks,
            },
            {
                path: 'other/reactMemo',
                Component: MyReactMemo,
            }
        ]
    },
    {
        path: 'login',
        Component: Login,
    }
]

export default createBrowserRouter(routes)